# -*-coding:utf-8-*-
import urllib2
import re
from bs4 import BeautifulSoup
class Geturls():
	def open(self, url):
		try:
			request = urllib2.Request(url)
			response = urllib2.urlopen(request)
			content = response.read().decode('utf-8')
			return content
		except urllib2.URLError, e:
			if hasattr(e,"code"):
				print e.code
			if hasattr(e,"reason"):
				print e.reason
	def distill(self, content):
		soup = BeautifulSoup(content, 'html.parser').find_all(href=re.compile("http://jobs.zhaopin.com/"))
		urls_temp = soup[:60]
		urls = []
		for url in urls_temp:
			pattern = re.compile('href="(.*?)"', re.S)
			url_temp = re.findall(pattern, str(url))
			urls.append(url_temp)
		return urls